package net.atomarrow.util.excel;

import java.util.ArrayList;
import java.util.List;

import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.util.CellRangeAddress;

public class ArrayData extends BaseData{
	private Object[] values;
	
	public ArrayData(int row, int column, Object[] values, CellStyle CellStyle) {
		super(row, column, CellStyle);
		this.values=values;
	}

	public Object[] getValues(){
		return values;
	}

	@Override
	public List<CellData> getCellDatas(List<CellRangeAddress> regions) {
		return getCellDatas(regions,null,null);
	}
	@Override
	public List<CellData> getCellDatas(List<CellRangeAddress> regions,
			ExcelFormatListener format,ExcelDataChangeListener dataChanger) {
		ArrayList<CellData> cellDatas = new ArrayList<CellData>();
		for(Object value:values){
			processRegions(regions);
			value=changeValueIfNecessary(value==null?"null":value.toString(), value==null?"":value, format);
			cellDatas.add(new CellData(row,column++,value==null?"":value.toString(),getCellStyle()));
		}
		return cellDatas;
	}

	@Override
	public int getEndColumn() {
		return column-1;
	}


	@Override
	public int getEndRow() {
		return row;
	}


}
